#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

import os
import signal

import psutil

from clickhouse.common.clickhouse_constants import TaskStage
from common.common import exter_attack, output_result_file
from common.const import ExecuteResultEnum
from common.parse_parafile import ParamFileUtil
from tpops.gaussdb.common.const import PermissionInfo, ActionResponse
from tpops.gaussdb.common.safe_get_information import ResourceParam
from tpops.gaussdb.common.log import log


class JobAbility:
    @staticmethod
    @exter_attack
    def query_job_permission(req_id, job_id, sub_id, data):
        param_inst = ResourceParam(req_id)
        _ = param_inst.get_param()
        output = PermissionInfo(user="rdadmin", group="rdadmin", fileMode="770")
        output_result_file(req_id, output.dict(by_alias=True))
        return ExecuteResultEnum.SUCCESS

    @staticmethod
    @exter_attack
    def abort_job(req_id, job_id, sub_id, data):
        """
        功能描述：执行中止任务, 页面触发, 不会执行后置任务
        参数：
        @pid： 请求ID
        @job_id： 主任务任务ID
        返回值：
        """
        pass

    @staticmethod
    @exter_attack
    def pause_job(req_id, job_id, sub_id, data):
        """
        功能描述：执行暂停任务，任务流程中触发, 会执行后置任务
        参数：
        @pid： 请求ID
        @job_id： 主任务任务ID
        返回值：CommonBodyResponse
        """
        pass
